package org.candy.core.convert.support;

import lombok.Data;
import org.candy.core.convert.ConversionService;
import org.candy.core.convert.converter.Converter;
import org.candy.ioc.annotation.IComponent;

@IComponent("conversionService")
public @Data class GenericConversionService implements ConversionService {

    private Converters converters = new Converters();

    @Override
    public <S, T> T convert(S source, Class<T> target) {
        return converters.convert(source, target);
    }

    @Override
    public void addConverter(Converter<?, ?> converter) {
        converters.add(converter);
    }
}
